<template>
  <div class="hot-recommend">
    <div class="header-container">
      <img src="@/assets/imgs/fan_video/hot.png" alt="">
      <h2 class="section-title">新热推荐</h2>
    </div>

    <!-- 第一个卡片（左视频右内容） -->
    <div class="hot-introduce">
      <div class="video-view" @mouseenter="playVideo(0)" @mouseleave="pauseVideo(0)">
        <video ref="video0" width="100%" height="100%" :poster="videos[0].poster" muted loop preload="metadata">
          <source :src="videos[0].url" type="video/mp4">
        </video>
        <div class="play-overlay" v-if="!isPlaying[0]">
          <span class="play-icon">▶</span>
        </div>
      </div>

      <div class="detail-view">
        <h3 class="video-title">汪汪队立大功 第一季 中文配音</h3>
        <div class="rating">
          <span class="score">9.1</span>
          <span class="count">205人点评</span>
        </div>
        <p class="description">
          《汪汪队立大功》是一部学龄前系列动画片，汪汪队由六只英雄狗狗组成：阿奇、毛毛、灰灰、路马、小喉、和天天。他们各有所长，在莱德的带领下完成各种救援任务。
        </p>
        <div class="actions">
          <button class="btn-primary">立即观看</button>
          <button class="btn-secondary">收藏</button>
        </div>
      </div>
    </div>


  </div>
</template>

<script setup>
import { ref } from 'vue'

const videos = ref([
  {
    url: 'http://www.iqiyi.com/v_1p39hal9f5o.html?share_sTime=0',
    poster: 'https://media.example.com/dog-patrol-poster.jpg'
  },

])

const videoRefs = ref([])
const isPlaying = ref([false, false])

const playVideo = (index) => {
  const video = videoRefs.value[index]
  if (video) {
    video.play()
    isPlaying.value[index] = true
  }
}

const pauseVideo = (index) => {
  const video = videoRefs.value[index]
  if (video) {
    video.pause()
    video.currentTime = 0
    isPlaying.value[index] = false
  }
}
</script>

<style lang="scss" scoped>
.hot-recommend {
 width: 100%;
  margin: 0 auto;

  .header-container {
    display: flex;
    align-items: center;


    img {
      width: 34px;
      height: 34px;

    }

    .section-title {
      font-size: 24px;
      color: #222;
      margin-bottom: 30px;
      padding-left: 15px;
    }
  }

}

.hot-introduce {
  display: flex;
  height: 340px;
  width: 100%;
  margin-bottom: 30px;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
  transition: transform 0.3s, box-shadow 0.3s;

  &:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
  }

  &.reverse {
    flex-direction: row-reverse;
  }

  .video-view {
    flex: 6;
    position: relative;
    background: #000;

    video {
      width: 100%;
      height: 100%;
      object-fit: cover;
      transition: opacity 0.3s;
    }

    .play-overlay {
      position: absolute;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      display: flex;
      align-items: center;
      justify-content: center;
      background: rgba(0, 0, 0, 0.3);

      .play-icon {
        color: white;
        font-size: 50px;
        opacity: 0.8;
        text-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
      }
    }

    &:hover video {
      opacity: 0.9;
    }
  }

  .detail-view {
    flex: 4;
    padding: 25px;
    background: white;
    display: flex;
    flex-direction: column;

    .video-title {
      font-size: 22px;
      color: #222;
      margin-bottom: 15px;
      line-height: 1.3;
    }

    .rating {
      margin-bottom: 20px;

      .score {
        font-size: 20px;
        color: #ffb400;
        font-weight: bold;
      }

      .count {
        font-size: 14px;
        color: #999;
        margin-left: 10px;
      }
    }

    .description {
      flex: 1;
      font-size: 14px;
      color: #666;
      line-height: 1.6;
      margin-bottom: 20px;
      display: -webkit-box;
      -webkit-line-clamp: 4;
      -webkit-box-orient: vertical;
      overflow: hidden;
    }

    .actions {
      display: flex;
      gap: 15px;

      .btn-primary {
        background: #00a1d6;
        color: white;
      }

      .btn-secondary {
        background: white;
        color: #00a1d6;
        border: 1px solid #00a1d6;
      }

      button {
        padding: 8px 20px;
        border-radius: 4px;
        border: none;
        font-size: 14px;
        cursor: pointer;
        transition: all 0.3s;

        &:hover {
          opacity: 0.9;
          transform: translateY(-2px);
        }
      }
    }
  }
}
</style>
